﻿#region Using Directives
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

#endregion

namespace Nihongo.GrammaticalPatterns
{
    public class ToBe : IGrammar
    {
        private readonly IGrammarStrategy _grammarStrategy;

        public ToBe(Word noun1, Word noun2)
        {
            _grammarStrategy = new Noun1WaNoun2(noun1, noun2);
        }

        public Sentence PlainPresentForm
        {
            get { return _grammarStrategy.PlainPresentForm; }
        }

        public Sentence PlainPastForm
        {
            get { return _grammarStrategy.PlainPastForm; }
        }

        public Sentence PlainPresentNegativeForm
        {
            get { return _grammarStrategy.PlainPresentNegativeForm; }
        }

        public Sentence PlainPastNegativeForm
        {
            get { return _grammarStrategy.PlainPastNegativeForm; }
        }

        public Sentence MasuPresentForm
        {
            get { return _grammarStrategy.MasuPresentForm; }
        }

        public Sentence MasuPresentNegativeForm
        {
            get { return _grammarStrategy.MasuPresentNegativeForm; }
        }

        public Sentence MasuPastForm
        {
            get { return _grammarStrategy.MasuPastForm; }
        }

        public Sentence MasuPastNegativeForm
        {
            get { return _grammarStrategy.MasuPastNegativeForm; }
        }

        private interface IGrammarStrategy
        {
            Sentence PlainPresentForm { get; }
            Sentence PlainPastForm { get; }
            Sentence PlainPresentNegativeForm { get; }
            Sentence PlainPastNegativeForm { get; }
            Sentence MasuPresentForm { get; }
            Sentence MasuPresentNegativeForm { get; }
            Sentence MasuPastForm { get; }
            Sentence MasuPastNegativeForm { get; }
        }

        private class Noun1WaNoun2 : IGrammarStrategy
        {
            private readonly DesuForm _desuForm = DesuForm.JaArimasenForm;
            private readonly Sentence _sentenceRoot;

            public Noun1WaNoun2(Word noun1, Word noun2)
            {
                SentenceBuilder sentence = new SentenceBuilder();
                sentence.Append(noun1, Particle.Wa, noun2);

                _sentenceRoot = sentence.ToSentence();
            }
            public Sentence PlainPresentForm
            {
                get { return Sentence.Concat(_sentenceRoot, new Word("だ")); }
            }

            public Sentence PlainPastForm
            {
                get { return Sentence.Concat(_sentenceRoot, new Word("だった")); }
            }

            public Sentence PlainPresentNegativeForm
            {
                get { return Sentence.Concat(_sentenceRoot, new Word("じゃない")); }
            }

            public Sentence PlainPastNegativeForm
            {
                get { return Sentence.Concat(_sentenceRoot, new Word("じゃなかった")); }
            }

            public Sentence MasuPresentForm
            {
                get { return Sentence.Concat(_sentenceRoot, _desuForm.PresentForm); }
            }

            public Sentence MasuPresentNegativeForm
            {
                get { return Sentence.Concat(_sentenceRoot, _desuForm.PresentNegativeForm); }
            }

            public Sentence MasuPastForm
            {
                get { return Sentence.Concat(_sentenceRoot, _desuForm.PastForm); }
            }

            public Sentence MasuPastNegativeForm
            {
                get { return Sentence.Concat(_sentenceRoot, _desuForm.PastNegativeForm); }
            }
        }
    }
}
